<?php
class Form_Book_Edition extends Zend_Form {
	
	public function init()
	{
		$this->addElement('text', 'isbn', array(
			'label'		=> 'ISBN',
			'filters' 	=> array('StripTags'),
			'validators' => array(new Zend_Validate_StringLength(10, 13))
		));
		
		$this->addElement('text', 'tytul', array(
			'label'		=> 'tytuł',
			'filters' => array('StripTags')
		));
	
		$this->addElement('select', 'glownyAutor', array(
			'label'		=> 'Główny autor',
		));
		
		foreach(AuthorManager::getInstance()->getAll() as $a) {
			$this->glownyAutor->addMultiOption($a->id, $a->imie . ' ' . $a->nazwisko);	
		}
		
		$this->addElement('text', 'jezyk', array(
			'label'		=> 'Język',
			'filters' => array('StripTags'),
			'validators' => array(new Zend_Validate_StringLength(2, 2))
		));
		
		$this->addElement('select', 'nosnik', array(
			'label'		=> 'Nosnik',
		));
		$this->nosnik->addMultiOptions(array(
							'papier' => 'papier',
							'plyta'	 => 'płyta',
							'elektroniczny' => 'elektroniczny',
							'inny' => 'inny'));
		
		$this->addElement('text', 'strony', array(
			'label'		=> 'Strony',
			'filters' => array('StripTags'),
			'validators' => array('Int')
		));
	
		$this->addElement('select', 'idWydawnictwa', array(
			'label'		=> 'Wydawnictwo',
		));
		
		foreach(PublishingManager::getInstance()->getAll() as $pub) {
			$this->idWydawnictwa->addMultiOption($pub->nazwa, $pub->nazwa);	
		}
		
		$this->addElement('text', 'rok', array(
			'label'		=> 'Rok',
			'filters' => array('StripTags'),
			'validators' => array('Int')
		));
		
		$this->addElement('text', 'miejsceWydania', array(
			'label'		=> 'Miejsce wydania',
			'filters' => array('StripTags'),
			'validators' => array(new Zend_Validate_StringLength(2, 64))
		));
		
		$this->addElement('hidden', 'idKsiazki');
		$this->addElement('hidden', 'catId');
		
		$this->addElement('submit', 'save', array(
			'label'		=> 'Zapisz'
		));
	}
	
}